<template>
    <view>
        <view class="plate">
            <titleBox title="服务内容"></titleBox>
            <ServerBuy v-if="Buy"></ServerBuy>
            <view class="serveList" :class="{ Used: Buy }" @click="Usede">
                <view class="iconfont icon-yishiyong color" v-if="Buy"></view>
                <view class="product">
                    <view class="serial" v-if="Buy">1515</view>
                    <image :src="headImg" mode="aspectFill" class="product_img"></image>
                </view>
                <view class="product_content_buy" v-if="Buy">
                    <view class="flex-1 d-flex f-column j-sb">
                        <text class="ellipsis title size30 m-top10">商品或服务名1</text>
                        <text class="price size32 m-bot10">￥399.99</text>
                    </view>
                    <view class="Options">
                        <view class="Options-list">分享好友</view>
                        <view class="Options-list">立即使用</view>
                    </view>
                </view>
                <view class="product_content" v-else>
                    <text class="ellipsis title size30">商品或服务名1</text>
                    <text class="ellipsis Abstract size28">摘要摘要摘要摘要摘要摘要摘要</text>
                    <view class="row j-sb a-center">
                        <view class="d-flex f-column">
                            <text class="color_99 size26">5次</text>
                            <text class="price size28 m-top8">￥399.99</text>
                        </view>
                        <view class="look a-self-end">查看详情</view>
                    </view>
                </view>
            </view>
            <view class="serveList" :class="{ Used: Buy }">
                <view class="iconfont icon-yishiyong color" v-if="Buy"></view>
                <view class="product">
                    <view class="serial" v-if="Buy">1515</view>
                    <image :src="headImg" mode="aspectFill" class="product_img"></image>
                </view>
                <view class="product_content_buy" v-if="Buy">
                    <view class="flex-1 d-flex f-column j-sb">
                        <text class="ellipsis title size30 m-top10">商品或服务名1</text>
                        <text class="price size32 m-bot10">￥399.99</text>
                    </view>
                    <view class="Options">
                        <view class="Options-list">分享好友</view>
                        <view class="Options-list" @click.stop="Show = true">立即使用</view>
                    </view>
                </view>
                <view class="product_content" v-else>
                    <text class="ellipsis title size30">商品或服务名1</text>
                    <text class="ellipsis Abstract size28">摘要摘要摘要摘要摘要摘要摘要</text>
                    <view class="row j-sb a-center">
                        <view class="d-flex f-column">
                            <text class="color_99 size26">5次</text>
                            <text class="price size28 m-top8">￥399.99</text>
                        </view>
                        <view class="look a-self-end">查看详情</view>
                    </view>
                </view>
            </view>
        </view>

        <view class="Pop" v-if="Show">
            <useNow></useNow>
            <view class="iconfont icon-guanbi white size60 p-top30" @click.stop="Show = false"></view>
        </view>
    </view>
</template>

<script>
    import { mapState } from 'vuex'
    import ServerBuy from '@/subCard/components/ServerBuy.vue'
    import titleBox from '@/subCard/components/titleBox.vue'
    import useNow from '@/subCard/components/useNow.vue'
    export default {
        props: ['Buy'],
        components: {
            ServerBuy,
            titleBox,
            useNow
        },
        data() {
            return {
                headImg: 'https://msraimgcdn.mogoie.com/6099/1709797684310.JPG',
                Show: false
            }
        },
        methods: {
            Usede() {
                if (!this.Buy) return
                this.toUrl(`/subCard/userDetails`)
            }
        },
        computed: {
            ...mapState(['color'])
        }
    }
</script>

<style lang="scss" scoped>
    .plate {
        width: 690rpx;
        margin: 0 auto;
        background-color: #ffffff;
        padding: 20rpx;
        border-radius: 10rpx;
        margin-top: 24rpx;
    }
    .titleBox {
        width: 100%;
        padding-left: 20rpx;
        color: var(--color);
        font-size: 30rpx;
        position: relative;
    }
    .titleBox::before {
        content: '';
        width: 4rpx;
        height: 30rpx;
        background-color: var(--color);
        position: absolute;
        left: 0;
        top: 50%;
        transform: translate(0, -50%);
    }

    .serveList {
        width: 100%;
        padding: 20rpx 0;
        display: flex;
        position: relative;
    }
    .product {
        width: 170rpx;
        height: 170rpx;
        border: 1rpx solid #f7f7f7;
        border-radius: 10rpx;
        display: flex;
        justify-content: center;
        align-items: center;
        overflow: hidden;
        position: relative;
        &-img {
            width: 100%;
            height: 100%;
        }
        .serial {
            background-color: var(--color);
            padding: 2rpx 20rpx;
            color: #ffffff;
            font-size: 22rpx;
            position: absolute;
            top: 0;
            left: 0;
            z-index: 10;
            border-radius: 0 0 10rpx 0;
        }
    }
    .product_content {
        flex: 1;
        height: 180rpx;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        margin-left: 24rpx;
    }

    .look {
        width: 160rpx;
        height: 60rpx;
        border: 1rpx solid #f2f2f2;
        display: flex;
        justify-content: center;
        align-items: center;
        color: var(--color);
        font-size: 24rpx;
        border-radius: 30rpx;
    }
    .title {
        color: #000;
    }
    .Abstract {
        color: #333333;
    }
    .price {
        color: #990000;
    }
    .product_content_buy {
        flex: 1;
        display: flex;
        margin-left: 24rpx;
        .Options {
            display: flex;
            flex-direction: column;
            justify-content: space-evenly;
            &-list {
                width: 160rpx;
                height: 60rpx;
                border: 1rpx solid #f2f2f2;
                display: flex;
                justify-content: center;
                align-items: center;
                color: var(--color);
                font-size: 24rpx;
                border-radius: 30rpx;
            }
        }
    }
    .Used {
        .serial {
            background-color: #ccc;
        }
        .product_img {
            opacity: 0.5;
        }
        .title,
        .price {
            color: #ccc;
        }
        .Options-list {
            color: #ccc;
        }
        .icon-yishiyong {
            position: absolute;
            font-size: 120rpx;
            left: 22%;
            top: 50%;
            transform: translate(0, -50%);
            z-index: 10;
        }
    }

    .Pop {
        width: 100%;
        height: 100vh;
        position: fixed;
        inset: 0;
        z-index: 100;
        background-color: rgba(0, 0, 0, 0.2);
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
    }
</style>
